algalcommand.io.xml
Class XMLFormatter
java.lang.Object
algalcommand.io.xml.XMLFormatter
- All Implemented Interfaces:
- java.io.Serializable
public final class XMLFormatter
- extends java.lang.Object
- implements java.io.Serializable
The SAX XML parser packaged with Java is not thread safe and fails miserably
in the true multithreaded application such as this. As such, this class is
part of a bare-bones XML writing and reading parser that is fully thread safe.
This class is simply used to convert between java Strings and XML text (which
must use escape sequences for certain characters).
The characters that need to be escaped (and their corresponding escapes)
are:
& - &
" - "
' - '
< - <
> - >
Copyright Owner:
Michigan State University, license number TEC2011-002101Prov
- See Also:
- Serialized Form
|
Field Summary |
static java.lang.String |
INDENT
|
|
Method Summary |
java.lang.String |
removeComments(java.lang.String input)
|
java.lang.String |
stringToXML(java.lang.String string)
Formats the given string for XML by substituting characters with special
meaning to their escape sequences. |
java.lang.String |
XMLToString(java.lang.String xml)
Parses an XML formatted string and returns the Java String that it
represents. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
INDENT
public static final java.lang.String INDENT
- See Also:
- Constant Field Values
XMLFormatter
public XMLFormatter()
- Constructor
stringToXML
public java.lang.String stringToXML(java.lang.String string)
- Formats the given string for XML by substituting characters with special
meaning to their escape sequences.
- Parameters:
string - A Java String that you wish to convert to XML
- Returns:
- The XML representation of
string
XMLToString
public java.lang.String XMLToString(java.lang.String xml)
- Parses an XML formatted string and returns the Java String that it
represents.
- Parameters:
xml - an XML string
- Returns:
- A string with all of the XML escapes returned to their
corresponding characters.
removeComments
public java.lang.String removeComments(java.lang.String input)